using System;
using Abp.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Abp.AspNetCore.Mvc.Authorization;

/// <summary>
/// This attribute is used on an action of an MVC <see cref="Controller"/>
/// to make that action usable only by authorized users. 
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class AbpMvcAuthorizeAttribute : AuthorizeAttribute, IAbpAuthorizeAttribute
{
    /// <inheritdoc/>
    public string[] Permissions { get; set; }

    /// <inheritdoc/>
    public bool RequireAllPermissions { get; set; }

    /// <summary>
    /// Creates a new instance of <see cref="AbpMvcAuthorizeAttribute"/> class.
    /// </summary>
    /// <param name="permissions">A list of permissions to authorize</param>
    public AbpMvcAuthorizeAttribute(params string[] permissions)
    {
        Permissions = permissions;
    }
}